<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j" template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form id="editUser" enctype="multipart/form-data">
			
			<rich:panel>
				<f:facet name="header">#{messages.editUser}</f:facet>
				<h:panelGrid columns="2">

					<s:div>
						<a:outputPanel id="info">
							<s:graphicImage rendered="#{userHome.image!=null}"
								value="#{userHome.image}" />

							<s:graphicImage rendered="#{userHome.instance.picture!=null}"
								value="#{userHome.instance.picture}" />


							<s:decorate id="imageSelect" template="/layout/edit.xhtml"
								rendered="#{userHome.instance.picture==null}">
								<ui:define name="label">#{messages.uploadImage}</ui:define>
								<s:fileUpload id="picture" data="#{userHome.instance.picture}" accept="image/png,image/jpg,image/jpeg">
								<a:support event="" rerender="info"></a:support>
								</s:fileUpload>
							</s:decorate>
						</a:outputPanel>
						<br/>
						<center>
							<s:button action="#{userHome.clearImage}" rendered="#{userHome.instance.picture!=null}"
								value="#{messages['btn.removePicture']}">
								<a:support event="" reRender="info" />
							</s:button>
						</center>
					</s:div>
					<s:div>
						<s:decorate id="nameField" template="/layout/edit.xhtml">
							<ui:define name="label">#{messages.userName}</ui:define>
							<h:inputText id="name" required="true"
								value="#{userHome.instance.username}" />
						</s:decorate>

						<s:decorate id="email" template="/layout/edit.xhtml">
							<ui:define name="label">#{messages.email}</ui:define>
							<h:inputText id="name" required="true"
								value="#{userHome.instance.email}" />
						</s:decorate>

						<s:decorate id="name" template="/layout/edit.xhtml">
							<ui:define name="label">#{messages.name}</ui:define>
							<h:inputText id="name" required="true"
								value="#{userHome.instance.name}" />
						</s:decorate>
						<s:decorate id="surname" template="/layout/edit.xhtml">
							<ui:define name="label">#{messages.surname}</ui:define>
							<h:inputText id="name" required="true"
								value="#{userHome.instance.surname}" />
						</s:decorate>

						<s:decorate id="roleSelect" template="/layout/edit.xhtml"
							rendered="#{userRoleList.resultList!=null and (identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant'))}">
							<ui:define name="label">#{messages.selectRoles}</ui:define>
							<rich:pickList id="selOrg" value="#{userHome.instance.userRoles}">
								<s:selectItems value="#{userRoleList.resultList}"
									var="_userRole" label="#{_userRole.roleName}" />
								<s:convertEntity></s:convertEntity>
							</rich:pickList>
						</s:decorate>
					</s:div>
				</h:panelGrid>

			</rich:panel>

			<div class="actionButtons">
				<h:commandButton id="save" value="Save" action="#{userHome.persist}"
					rendered="#{!userHome.managed}" />
				<h:commandButton id="update" value="Save"
					action="#{userHome.update}" rendered="#{userHome.managed}" />
				<h:commandButton id="delete" value="Delete"
					action="#{userHome.remove}" immediate="true"
					rendered="#{userHome.managed}" />
				<s:button id="cancel" value="Cancel"
					view="/Settings/User/viewUser.xhtml">
					<!--<f:param name="path" value="#{userHome.getPath()}"/>
					-->
				</s:button>
			</div>

		</h:form>

	</ui:define>

</ui:composition>
